package com.cpl.servlet;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.Writer;
@WebServlet(name="hello",urlPatterns = "/hello")
public class TryDemo extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        super.doGet(req, resp);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        req.setCharacterEncoding("utp-8");
        resp.setCharacterEncoding("utp-8");
        resp.setContentType("text/html");
        String name=req.getParameter("name");
        Writer writer = resp.getWriter();
        writer.write("<!DOCTYPE html>            \n" +
                "<html lang=\"en\">           \n" +
                "<head>                     \n" +
                "    <meta charset=\"UTF-8\"> \n" +
                "    <title>Title</title>   \n" +
                "</head>                    \n" +
                "<body>                     \n" +
                "<h>站点成功启动</h>              \n" +
                "</body>                    \n" +
                "</html>                    ");
        writer.flush();
        writer.close();
    }
}
